home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume0 / awm / part07 < prev    next >
Encoding:
Internet Message Format  |  1988-08-09  |  47.1 KB

  1. Path: uunet!wyse!mikew
  2. From: mikew@wyse.wyse.com (Mike Wexler)
  3. Newsgroups: comp.sources.x
  4. Subject: v00i008:  Ardent Window Manager(X11), Part07/13
  5. Message-ID: <1631@wyse.wyse.com>
  6. Date: 10 Aug 88 00:18:58 GMT
  7. Sender: news@wyse.wyse.com
  8. Lines: 1495
  9. Approved: mikew@wyse.com
  10.  
  11. Submitted-by: jkh@ardent (Jordan Hubbard)
  12. Posting-number: Volume 0, Issue 8
  13. Archive-name: awm/part07
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 7 (of 13)."
  22. # Contents:  awm/Neaten.c awm/Resize.c awm/globals.c
  23. # Wrapped by mikew@wyse on Mon Aug  8 12:01:45 1988
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f awm/Neaten.c -a "${1}" != "-c" ; then 
  26.   echo shar: Will not over-write existing file \"awm/Neaten.c\"
  27. else
  28. echo shar: Extracting \"awm/Neaten.c\" \(14785 characters\)
  29. sed "s/^X//" >awm/Neaten.c <<'END_OF_awm/Neaten.c'
  30. X#ident   "%W% %G%"
  31. X
  32. X
  33. X
  34. X#ifndef lint
  35. Xstatic char *rcsid_Neaten_c = "$Header: Neaten.c,v 1.2 88/06/17 15:26:00 jkh Exp $";
  36. X#endif  lint
  37. X
  38. X#include "X11/copyright.h"
  39. X/*
  40. X *
  41. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  42. X *
  43. X * Copyright 1987 by Jordan Hubbard.
  44. X *
  45. X *
  46. X *                         All Rights Reserved
  47. X *
  48. X * Permission to use, copy, modify, and distribute this software and its
  49. X * documentation for any purpose and without fee is hereby granted,
  50. X * provided that the above copyright notice appear in all copies and that
  51. X * both that copyright notice and this permission notice appear in
  52. X * supporting documentation, and that the name of Ardent Computer
  53. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  54. X * pertaining to distribution of the software without specific, written
  55. X * prior permission.
  56. X *
  57. X */
  58. X
  59. X/*
  60. X * MODIFICATION HISTORY
  61. X *
  62. X * 002 -- Jordan Hubbard, Ardent Computer.
  63. X *  Changes to work with awm, specifically reparented windows.
  64. X */
  65. X
  66. X#include "awm.h"
  67. X     
  68. X#ifdef NEATEN
  69. X     
  70. X#include "X11/Xutil.h"
  71. X#include "X11/cursorfont.h"
  72. X#include "neaten.ext.h"
  73. X
  74. Xstatic void GetIconHints();
  75. Xstatic void GetName();
  76. Xextern Boolean IsIcon();
  77. Xextern int neaten_debug_level;
  78. X
  79. X#define TOP_LEVEL (awi->frame ? awi->frame : awi->client)
  80. X
  81. X/* ARGSUSED */
  82. XBoolean Neaten(window, mask, button, x, y)
  83. XWindow window;                          /* Event window. */
  84. Xint mask;                               /* Button/key mask. */
  85. Xint button;                               /* Button event detail. */
  86. Xint x, y;                               /* Event mouse position. */
  87. X{
  88. X     Window junk_window;
  89. X     Window w;
  90. X     Window icon_window;
  91. X     Window stacktop;
  92. X     Window *children;
  93. X     XWindowAttributes attrs;
  94. X     XSizeHints hints;
  95. X     XWindowChanges  wc;
  96. X     Status rstatus;
  97. X     char name[50];
  98. X     int junk;
  99. X     int root_x, root_y;
  100. X     int root_width, root_height;
  101. X     int icon_x, icon_y;
  102. X     int icon_width, icon_height;
  103. X     int icon_border;
  104. X     int window_x, window_y;
  105. X     int window_width, window_height;
  106. X     int rval;
  107. X     int ix;
  108. X     int iconic;
  109. X     int tiled;
  110. X     int adjustment;
  111. X     int priority;
  112. X     int priority_increment;
  113. X     unsigned int nchildren;
  114. X     unsigned int mapped_children = 0;
  115. X     unsigned int opened_children = 0;
  116. X     unsigned int  wcmask;
  117. X     Placement primary;
  118. X     Placement secondary;
  119. X     Boolean is_iconic;
  120. X     Cursor rtlcursor;
  121. X     XFontStruct *font;
  122. X     GC gc;
  123. X     AwmInfoPtr awi;
  124. X
  125. X     Entry("Neaten")
  126. X
  127. X     font = (XFontStruct *) XLoadQueryFont(dpy, "cursor");
  128. X     gc = DefaultGC(dpy, scr);
  129. X     XSetFont(dpy, gc, font->fid);
  130. X     
  131. X     rtlcursor = XCreateFontCursor(dpy, XC_rtl_logo);
  132. X     
  133. X     XGrabPointer(dpy, RootWindow(dpy, scr), FALSE, (unsigned int) 0,
  134. X          GrabModeAsync, GrabModeAsync,
  135. X          (Window) None, rtlcursor, CurrentTime);
  136. X     
  137. X     if (AbsMinWidth == 0)
  138. X      AbsMinWidth = DEFAULT_ABS_MIN;
  139. X     if (AbsMinHeight == 0)
  140. X      AbsMinHeight = DEFAULT_ABS_MIN;
  141. X     
  142. X     XGetGeometry(dpy, RootWindow(dpy, scr), &junk_window,
  143. X          &root_x, &root_y,
  144. X          &root_width, &root_height,
  145. X          &junk, &junk);
  146. X     
  147. X     Neaten_Initialize(root_width+SEPARATION,
  148. X               root_height+SEPARATION,
  149. X               AbsMinWidth, AbsMinHeight);
  150. X     
  151. X     if (strcmp(PrimaryIconPlacement, "Closest") == 0)
  152. X      primary = Place_Closest;
  153. X     else if (strcmp(PrimaryIconPlacement, "Top") == 0)
  154. X      primary = Place_Top;
  155. X     else if (strcmp(PrimaryIconPlacement, "Bottom") == 0)
  156. X      primary = Place_Bottom;
  157. X     else if (strcmp(PrimaryIconPlacement, "Left") == 0)
  158. X      primary = Place_Left;
  159. X     else if (strcmp(PrimaryIconPlacement, "Right") == 0)
  160. X      primary = Place_Right;
  161. X     else
  162. X      primary = Place_Top;
  163. X     
  164. X     if (strcmp(SecondaryIconPlacement, "Closest") == 0)
  165. X      secondary = Place_Closest;
  166. X     else if (strcmp(SecondaryIconPlacement, "Top") == 0)
  167. X      secondary = Place_Top;
  168. X     else if (strcmp(SecondaryIconPlacement, "Bottom") == 0)
  169. X      secondary = Place_Bottom;
  170. X     else if (strcmp(SecondaryIconPlacement, "Left") == 0)
  171. X      secondary = Place_Left;
  172. X     else if (strcmp(SecondaryIconPlacement, "Right") == 0)
  173. X      secondary = Place_Right;
  174. X     else if (strcmp(SecondaryIconPlacement, "Center") == 0)
  175. X      secondary = Place_Center;
  176. X     else
  177. X      secondary = Place_Left;
  178. X     
  179. X     Neaten_Icon_Placement(primary, secondary);
  180. X     
  181. X     if (XQueryTree(dpy, RootWindow(dpy, scr), &junk_window,
  182. X            &junk_window, &children, &nchildren))
  183. X     {
  184. X      for (ix = 0; ix < nchildren; ix++)
  185. X      {
  186. X           XGetWindowAttributes(dpy, children[ix], &attrs);        
  187. X           
  188. X           if ((attrs.map_state != IsUnmapped) &&
  189. X           (attrs.override_redirect == False) &&
  190. X           (awi = GetAwmInfo(children[ix])))
  191. X           {
  192. X            w = children[ix];
  193. X            if (w != TOP_LEVEL && w != awi->icon)
  194. X             continue;
  195. X            mapped_children++;
  196. X            
  197. X            is_iconic = IsIcon(w, (Window *) NULL);
  198. X            
  199. X            if (is_iconic == TRUE)
  200. X            {
  201. X             window_x = window_y =
  202. X                  window_width = window_height = 0;
  203. X             icon_x = attrs.x;
  204. X             icon_y = attrs.y;
  205. X             icon_width = attrs.width;
  206. X             icon_height = attrs.height;
  207. X             
  208. X             adjustment = SEPARATION;
  209. X             icon_width += adjustment;
  210. X             icon_height += adjustment;
  211. X            }
  212. X            else
  213. X            {
  214. X             window_x = attrs.x;
  215. X             window_y = attrs.y;
  216. X             window_width = attrs.width;
  217. X             window_height = attrs.height;
  218. X             
  219. X             window_x -= attrs.border_width;
  220. X             window_y -= attrs.border_width;
  221. X             
  222. X             adjustment = (2 * attrs.border_width) + SEPARATION;
  223. X             window_width += adjustment;
  224. X             window_height += adjustment;
  225. X             
  226. X             GetIconHints(w, &icon_x, &icon_y,
  227. X                      &icon_width, &icon_height, &icon_border);
  228. X             
  229. X             icon_x -= icon_border;
  230. X             icon_y -= icon_border;
  231. X             icon_width += (2 * icon_border) + SEPARATION;
  232. X             icon_height += (2 * icon_border) + SEPARATION;
  233. X             
  234. X             opened_children++;
  235. X             stacktop = TOP_LEVEL;
  236. X            }
  237. X            
  238. X            GetName(w, name);
  239. X            if(neaten_debug_level)
  240. X            {
  241. X             printf("%s\ticonic = %s\n",
  242. X                name, (is_iconic ? "TRUE" : "FALSE"));
  243. X             printf("\ticon: x = %d y = %d width = %d height = %d\n",
  244. X                icon_x, icon_y, icon_width, icon_height);
  245. X             if (is_iconic != TRUE)
  246. X                  printf("\twindow: x = %d y = %d width = %d height = %d\n",
  247. X                     window_x, window_y, window_width,
  248. X                     window_height);
  249. X            }
  250. X            
  251. X            Neaten_Identify((int) w, is_iconic,
  252. X                    NEATEN_TRUE, NEATEN_FALSE,
  253. X                    window_x, window_y,
  254. X                    window_width, window_height,
  255. X                    NEATEN_TRUE, NEATEN_FALSE,
  256. X                    icon_x, icon_y,
  257. X                    icon_width, icon_height,
  258. X                    (unsigned long) adjustment);
  259. X            
  260. X            rstatus = XGetNormalHints(dpy, w, &hints);
  261. X            if (rstatus != (Status) 0 && is_iconic != TRUE)
  262. X            {
  263. X             if (hints.flags & PMinSize)
  264. X             {
  265. X                  rval = Neaten_Set_Min((int) w,
  266. X                            hints.min_width+adjustment,
  267. X                            hints.min_height+adjustment);
  268. X                  if(neaten_debug_level)
  269. X                   printf("\tmin: width = %d height = %d status = %s\n",
  270. X                      hints.min_width, hints.min_height,
  271. X                      (rval ? "SUCCESS" : "FAILURE"));
  272. X             }
  273. X             if (hints.flags & PMaxSize) 
  274. X             {
  275. X                  rval = Neaten_Set_Max((int) w,
  276. X                            hints.max_width+adjustment,
  277. X                            hints.max_height+adjustment);
  278. X                  if(neaten_debug_level)
  279. X                   printf("\tmax: width = %d height = %d status = %s\n",
  280. X                      hints.max_width, hints.max_height,
  281. X                      (rval ? "SUCCESS" : "FAILURE"));            
  282. X             }
  283. X             if (hints.flags & (USSize | PSize))
  284. X             {
  285. X                  rval = Neaten_Set_Desired((int) w,
  286. X                            hints.width+adjustment,
  287. X                            hints.height+adjustment);
  288. X                  if(neaten_debug_level)
  289. X                   printf("\tdes: width = %d height = %d status = %s\n",
  290. X                      hints.width, hints.height,
  291. X                      (rval ? "SUCCESS" : "FAILURE"));            
  292. X             }
  293. X             
  294. X             /* if no max hints are given, set the max to the
  295. X                max of the desired and current size 
  296. X                */
  297. X             if (!(hints.flags & PMaxSize))
  298. X             {
  299. X                  int desired_width = hints.width+adjustment;
  300. X                  int desired_height = hints.height+adjustment;
  301. X                  
  302. X                  window_width = ((window_width > desired_width)
  303. X                          ? window_width :
  304. X                          desired_width);
  305. X                  window_height = ((window_height > desired_height) 
  306. X                           ? window_height :
  307. X                           desired_height);
  308. X                  rval = Neaten_Set_Max((int) w,
  309. X                            window_width,
  310. X                            window_height);
  311. X                  if(neaten_debug_level)
  312. X                   printf("\tmax: width = %d height = %d status = %s\n",
  313. X                      window_width-adjustment, window_height-adjustment,
  314. X                      (rval ? "SUCCESS" : "FAILURE"));
  315. X             }
  316. X            }
  317. X           }
  318. X      }
  319. X      
  320. X      if (UsePriorities == TRUE)
  321. X      {
  322. X           priority = MIN_PRIORITY;
  323. X           if (opened_children > 1)
  324. X            priority_increment = (MAX_PRIORITY - MIN_PRIORITY) /
  325. X             (opened_children - 1);
  326. X           for (ix = 0; ix < nchildren; ix++)
  327. X           {
  328. X            w = children[ix];
  329. X            awi = GetAwmInfo(w);
  330. X            if (!awi)
  331. X             continue;
  332. X            if (w != TOP_LEVEL && w != awi->icon)
  333. X             continue;
  334. X            is_iconic = IsIcon(w, (Window *) NULL);
  335. X            
  336. X            if (is_iconic != TRUE)
  337. X            {
  338. X             XGetWindowAttributes(dpy, w, &attrs);        
  339. X             if ((attrs.map_state != IsUnmapped) &&
  340. X                 (attrs.override_redirect == False))
  341. X             {
  342. X                  Neaten_Set_Priorities((int) w, priority, priority);
  343. X                  if (neaten_debug_level)
  344. X                  {
  345. X                   GetName(w, name);
  346. X                   printf("%s: priority = %d\n", name, priority);
  347. X                  }
  348. X                  priority += priority_increment;
  349. X             }
  350. X            }
  351. X           }
  352. X      }
  353. X      
  354. X      if (FixTopOfStack == TRUE)
  355. X      {
  356. X           Neaten_Set_Options((int) stacktop, NEATEN_FALSE, NEATEN_TRUE);
  357. X           if (neaten_debug_level)
  358. X           {
  359. X            GetName(stacktop, name);
  360. X            printf("stacktop = %s\n", name);
  361. X           }
  362. X      }
  363. X      
  364. X      if(neaten_debug_level)
  365. X           printf("mapped children = %d\topened_children = %d\n",
  366. X              mapped_children, opened_children);
  367. X      
  368. X      Neaten_Desktop((RetainSize == FALSE), (KeepOpen == FALSE), Fill);
  369. X      
  370. X      for (ix = 0; ix < nchildren; ix++)
  371. X      {
  372. X           w = children[ix];
  373. X           awi = GetAwmInfo(w);
  374. X           if (!awi)
  375. X            continue;
  376. X           if (w != TOP_LEVEL && w != awi->icon)
  377. X            continue;
  378. X           if (Neaten_Get_Geometry((int) w, &iconic, &tiled,
  379. X                       &window_x, &window_y,
  380. X                       &window_width, &window_height,
  381. X                       (unsigned long) &adjustment) == 0)
  382. X            continue;
  383. X           GetName(w, name);
  384. X           if(neaten_debug_level)
  385. X           {
  386. X            printf("%s iconic = %s  tiled = %s\n", name,
  387. X               (iconic ? "TRUE" : "FALSE"),
  388. X               (tiled ? "TRUE" : "FALSE"));
  389. X            printf("   x = %d, y = %d, width = %d, height = %d\n",
  390. X               window_x, window_y, window_width, window_height);
  391. X           }
  392. X           
  393. X           wc.x = window_x;
  394. X           wc.y = window_y;
  395. X           wc.width = window_width;
  396. X           wc.height = window_height;
  397. X           wcmask = CWX | CWY | CWWidth | CWHeight;
  398. X           
  399. X           if (iconic == NEATEN_TRUE)
  400. X           {
  401. X            is_iconic = IsIcon(w, &icon_window);
  402. X            if (is_iconic == TRUE)
  403. X            {
  404. X             wc.width -= adjustment;
  405. X             wc.height -= adjustment;
  406. X             
  407. X             XConfigureWindow(dpy, w, wcmask, &wc);
  408. X             if(tiled != NEATEN_TRUE)
  409. X                  XRaiseWindow(dpy, w);
  410. X            }
  411. X            else
  412. X            {
  413. X             /* have to go to the server to get the info, this
  414. X                could have been avoided if the the variable
  415. X                adjustment was a pointer to a structure that
  416. X                contained the information for the icon and the
  417. X                information for the window.  However, I chose
  418. X                not to mess with all that memory management
  419. X                */
  420. X             GetIconHints(w, &icon_x, &icon_y,
  421. X                      &icon_width, &icon_height, &icon_border);
  422. X             
  423. X             wc.x -= icon_border;
  424. X             wc.y -= icon_border;
  425. X             wc.width -= (2 * icon_border) + SEPARATION;
  426. X             wc.height -= (2 * icon_border) + SEPARATION;
  427. X             
  428. X             XAddToSaveSet(dpy, w);
  429. X             XUnmapWindow(dpy, TOP_LEVEL);
  430. X             XConfigureWindow(icon_window, wcmask, &wc);
  431. X             XMapWindow(dpy, icon_window);
  432. X             if (tiled != NEATEN_TRUE)
  433. X                  XRaiseWindow(dpy, icon_window);
  434. X            }
  435. X           }
  436. X           else
  437. X           {
  438. X            wc.width -= adjustment;
  439. X            wc.height -= adjustment;
  440. X            adjustment -= SEPARATION;
  441. X            wc.x += adjustment/2;
  442. X            wc.y += adjustment/2;
  443. X            /* I think this will be the outer win */
  444. X            ConfigureWindow(w, wcmask, &wc);
  445. X            if(tiled != NEATEN_TRUE)
  446. X             XRaiseWindow(dpy, TOP_LEVEL);
  447. X           }
  448. X      }
  449. X      
  450. X      if (FixTopOfStack == TRUE)
  451. X           XRaiseWindow(dpy, stacktop);
  452. X      
  453. X      XFree(children);
  454. X     }
  455. X     
  456. X     XBell(dpy, VOLUME_PERCENTAGE(Volume));
  457. X     XUngrabPointer(dpy, CurrentTime);
  458. X     Leave(FALSE)
  459. X}
  460. X
  461. Xstatic void
  462. X     GetIconHints(window, x, y, width, height, border)
  463. XWindow window;
  464. Xint *x, *y, *width, *height, *border;
  465. X{
  466. X     Window root;
  467. X     XWMHints *wmhints;
  468. X     XWindowAttributes attrs;
  469. X     int junk;
  470. X     
  471. X     *border = *x = *y = 0;
  472. X     /*
  473. X      * Process window manager hints.
  474. X      */ 
  475. X     if (wmhints = XGetWMHints(dpy, window)) 
  476. X     {
  477. X      if (wmhints->flags&IconWindowHint)
  478. X      {
  479. X           XGetWindowAttributes(dpy, wmhints->icon_window, &attrs);
  480. X           *x = attrs.x;
  481. X           *y = attrs.y;
  482. X           *width = attrs.width;
  483. X           *height = attrs.height;
  484. X           *border = attrs.border_width;
  485. X      }
  486. X      else if (wmhints->flags&IconPixmapHint) 
  487. X      {
  488. X           XGetWindowAttributes(dpy, wmhints->icon_pixmap, &attrs);
  489. X           *width = attrs.width;
  490. X           *height = attrs.height;
  491. X      }
  492. X      else
  493. X      {
  494. X           GetDefaultSize(window, width, height);
  495. X      }
  496. X     }
  497. X     else
  498. X     {
  499. X      GetDefaultSize(window, width, height);
  500. X     }
  501. X     
  502. X     /*
  503. X      * Fix up sizes by padding.
  504. X      */ 
  505. X     if (!wmhints || !(wmhints->flags&(IconPixmapHint|IconWindowHint))) {
  506. X      *width += (HIconPad << 1);
  507. X      *height += (VIconPad << 1);
  508. X     }
  509. X     
  510. X     if (wmhints && (wmhints->flags&IconPositionHint)) {
  511. X      *x = wmhints->icon_x;
  512. X      *y = wmhints->icon_y;
  513. X     }
  514. X}
  515. X
  516. Xstatic void
  517. X     GetName(w, name)
  518. XWindow w;
  519. Xchar *name;
  520. X{
  521. X     Status rstatus;
  522. X     char *s = (char *) NULL;
  523. X     
  524. X     
  525. X     rstatus = XFetchName(dpy, w, &s);
  526. X     
  527. X     if (rstatus != (Status) 0 && s != (char *) NULL)
  528. X     {
  529. X      strcpy(name, s);
  530. X      XFree(s);
  531. X     }
  532. X     else
  533. X     {
  534. X      strcpy(name, "UNKNOWN");
  535. X     }
  536. X}
  537. X
  538. Xvoid NeatenDebug(window, left, top, width, height, adjustment)
  539. Xint window;
  540. Xint left, top;
  541. Xint width, height;
  542. Xunsigned long adjustment;
  543. X{
  544. X     Window w = (Window) window;
  545. X     
  546. X     left += (int) ((float)adjustment/2.0);
  547. X     top += (int) ((float)adjustment/2.0);
  548. X     
  549. X     width -= adjustment;
  550. X     height -= adjustment;
  551. X     
  552. X     XMoveResizeWindow(dpy, w, left, top, width, height);
  553. X     XFlush(dpy);
  554. X}
  555. X#else /* NEATEN not installed */
  556. XBoolean Neaten(window, mask, button, x, y)
  557. XWindow window;                          /* Event window. */
  558. Xint mask;                               /* Button/key mask. */
  559. Xint button;                               /* Button event detail. */
  560. Xint x, y;                               /* Event mouse position. */
  561. X{
  562. X     fprintf(stderr, "awm: Warning: Neaten package not installed in ");
  563. X     fprintf(stderr, "this version of of awm.\n");
  564. X}
  565. X#endif NEATEN
  566. END_OF_awm/Neaten.c
  567. if test 14785 -ne `wc -c <awm/Neaten.c`; then
  568.     echo shar: \"awm/Neaten.c\" unpacked with wrong size!
  569. fi
  570. # end of overwriting check
  571. fi
  572. if test -f awm/Resize.c -a "${1}" != "-c" ; then 
  573.   echo shar: Will not over-write existing file \"awm/Resize.c\"
  574. else
  575. echo shar: Extracting \"awm/Resize.c\" \(15515 characters\)
  576. sed "s/^X//" >awm/Resize.c <<'END_OF_awm/Resize.c'
  577. X#ident   "%W% %G%"
  578. X
  579. X
  580. X
  581. X#ifndef lint
  582. Xstatic char *rcsid_Resize_c = "$Header: Resize.c,v 1.1 88/06/15 15:01:04 jkh Exp $";
  583. X#endif    lint
  584. X
  585. X#include "X11/copyright.h"
  586. X/*
  587. X *
  588. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  589. X *
  590. X * Copyright 1987 by Jordan Hubbard.
  591. X *
  592. X *
  593. X *                         All Rights Reserved
  594. X *
  595. X * Permission to use, copy, modify, and distribute this software and its
  596. X * documentation for any purpose and without fee is hereby granted,
  597. X * provided that the above copyright notice appear in all copies and that
  598. X * both that copyright notice and this permission notice appear in
  599. X * supporting documentation, and that the name of Ardent Computer
  600. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  601. X * pertaining to distribution of the software without specific, written
  602. X * prior permission.
  603. X *
  604. X */
  605. X
  606. X/*
  607. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  608. X *
  609. X *                         All Rights Reserved
  610. X *
  611. X * Permission to use, copy, modify, and distribute this software and its
  612. X * documentation for any purpose and without fee is hereby granted,
  613. X * provided that the above copyright notice appear in all copies and that
  614. X * both that copyright notice and this permission notice appear in
  615. X * supporting documentation, and that the name of Digital Equipment
  616. X * Corporation not be used in advertising or publicity pertaining to
  617. X * distribution of the software without specific, written prior permission.
  618. X *
  619. X *
  620. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  621. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  622. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  623. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  624. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  625. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  626. X * SOFTWARE.
  627. X */
  628. X
  629. X/*
  630. X * MODIFICATION HISTORY
  631. X *
  632. X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  633. X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group
  634. X *        Convert to X11
  635. X * 002 -- Jordan Hubbard, U.C. berkeley.
  636. X *    Added alternate placement of resize window, code for title bar
  637. X *     support.
  638. X */
  639. X
  640. X#include "awm.h"
  641. X#include "X11/Xutil.h"
  642. X
  643. X#define max(a,b) ( (a) > (b) ? (a) : (b) )
  644. X#define min(a,b) ( (a) > (b) ? (b) : (a) )
  645. X#define makemult(a, b) ((b==1) ? (a) : (((int)((a) / (b))) * (b)) )
  646. X
  647. XBoolean Resize(window, mask, button, x0, y0)
  648. XWindow window;                          /* Event window. */
  649. Xint mask;                               /* Button/key mask. */
  650. Xint button;                             /* Button event detail. */
  651. Xint x0, y0;                             /* Event mouse position. */
  652. X{
  653. X     XWindowAttributes client_info;    /* client window info. */
  654. X     XWindowAttributes frame_info;    /* frame window info */
  655. X     int x1, y1;                        /* fixed box corner   */
  656. X     int x2, y2;                        /* moving box corner   */
  657. X     int x, y;
  658. X     int xinc, yinc;
  659. X     int minwidth, minheight;
  660. X     int maxwidth, maxheight;
  661. X     int defwidth, defheight;
  662. X     int ox, oy;            /* which quadrant of window */
  663. X     int pop_x, pop_y;            /* location of pop window */
  664. X     int hsize, vsize;            /* dynamic size */
  665. X     int delta;    
  666. X     int junk_x, junk_y;
  667. X     int ptrmask;            /* pointer status word */
  668. X     int num_vectors;            /* Number of vectors to XDraw. */
  669. X     Window assoc;            /* Window represented by the icon. */
  670. X     Window sub_win;            /* Mouse query sub window. */
  671. X     Window root;            /* Root query window. */
  672. X     XEvent button_event, *b_ev;    /* Button event packet. */
  673. X     XSegment box[MAX_BOX_VECTORS];    /* Box drawing vertex buffer. */
  674. X     XSegment zap[MAX_ZAP_VECTORS];    /* Zap drawing vertex buffer. */
  675. X     Boolean stop;            /* Should the window stop changing? */
  676. X     XSizeHints sizehints;
  677. X     XWindowChanges values;
  678. X     int width_offset, height_offset;    /* to subtract if resize increments */
  679. X     int x_offset, y_offset;        /* add to pointer to get anchor */
  680. X     AwmInfoPtr awi;
  681. X     int (*storegrid_func)();        /* which StoreGrid routine to use */
  682. X     int (*storebox_func)();        /* which StoreBox routing to use */
  683. X     int buttonConfirmEvent;
  684. X
  685. X     Entry("Resize")
  686. X
  687. X     /*
  688. X      * Do nothing if the event window is the root window.
  689. X      */
  690. X     if (window == RootWindow(dpy, scr))
  691. X      Leave(FALSE)
  692. X
  693. X     /*
  694. X      * Gather info about the event window.
  695. X      */
  696. X     awi = GetAwmInfo(window);
  697. X     if (!awi)
  698. X      Leave(FALSE)
  699. X     /*
  700. X      * Do not resize an icon window.
  701. X      */
  702. X     if (window == awi->icon)
  703. X      Leave(FALSE)
  704. X
  705. X     window = awi->client;
  706. X     b_ev = &button_event;
  707. X     buttonConfirmEvent = ButtonRelease;
  708. X
  709. X     status = XGetWindowAttributes(dpy, window, &client_info);
  710. X     if (status == FAILURE)
  711. X      Leave(FALSE)
  712. X
  713. X     if (awi->frame) { /* we have to compensate */
  714. X      status = XGetWindowAttributes(dpy, awi->frame, &frame_info);
  715. X      client_info.y = frame_info.y;
  716. X      client_info.x = frame_info.x;
  717. X      if (status == FAILURE)
  718. X           Leave(FALSE)
  719. X      if (awi->attrs & AT_TITLE)
  720. X           client_info.y += titleHeight + 2;
  721. X      if (awi->attrs & AT_BORDER) {
  722. X           client_info.x += BContext + 1;
  723. X           if (!(awi->attrs & AT_TITLE))
  724. X            client_info.y += BContext + 1;
  725. X      }
  726. X     }
  727. X
  728. X     /*
  729. X      * Clear The vector buffers.
  730. X      */
  731. X     bzero(box, sizeof(box));
  732. X     if (Zap)
  733. X      bzero(zap, sizeof(zap));
  734. X     storegrid_func = StoreGridBox;
  735. X     storebox_func = StoreBox;
  736. X
  737. X     /*
  738. X      * If we are here then we have a resize operation in progress.
  739. X      */
  740. X     
  741. X     /*
  742. X      * Turn on the resize cursor.
  743. X      */
  744. X     grab_pointer();
  745. X     /*
  746. X      * calculate fixed point (x1, y1) and varying point (x2, y2).
  747. X      */
  748. X     hsize = defwidth = client_info.width;
  749. X     vsize = defheight = client_info.height;
  750. X     x1 = client_info.x;
  751. X     y1 = client_info.y;
  752. X     x2 = x1 + hsize;
  753. X     y2 = y1 + vsize;
  754. X
  755. X     /*
  756. X      * Get the event window resize hint.
  757. X      */
  758. X     sizehints.flags = 0;
  759. X     XGetSizeHints(dpy, window, &sizehints, XA_WM_NORMAL_HINTS); 
  760. X     CheckConsistency(&sizehints);
  761. X
  762. X     /* until there are better WM_HINTS, we'll assume that the client's
  763. X      * minimum width and height are the appropriate offsets to subtract
  764. X      * when resizing with an explicit resize increment.
  765. X      */
  766. X     if ((sizehints.flags & PMinSize) && (sizehints.flags & PResizeInc)) {
  767. X      width_offset = sizehints.min_width;
  768. X      height_offset = sizehints.min_height;
  769. X     } else
  770. X      width_offset = height_offset = 0;
  771. X     /*
  772. X      * decide what resize mode we are in. Always rubberband if window
  773. X      * is too small.
  774. X      */
  775. X     if (client_info.width > 2 && client_info.height > 2) {
  776. X      ox = ((x0 - client_info.x) * 3) / client_info.width;
  777. X      oy = ((y0 - client_info.y) * 3) / client_info.height;
  778. X      if ((ox + oy) & 1) {
  779. X           if (ox & 1) {
  780. X            /* fix up size hints so that we will never change width */
  781. X            sizehints.min_width = sizehints.max_width =
  782. X             client_info.width;
  783. X            if ((sizehints.flags & PMinSize) == 0) {
  784. X             sizehints.min_height = 0;
  785. X             sizehints.flags |= PMinSize;
  786. X            }
  787. X            if ((sizehints.flags & PMaxSize) == 0) {
  788. X             sizehints.max_height = DisplayHeight(dpy, scr);
  789. X             sizehints.flags |= PMaxSize;
  790. X            }
  791. X           }
  792. X           if (oy & 1) {
  793. X            /* fix up size hints so that we will never change height */
  794. X            sizehints.min_height = sizehints.max_height =
  795. X             client_info.height;
  796. X            if ((sizehints.flags & PMinSize)==0) {
  797. X             sizehints.min_width = 0;
  798. X             sizehints.flags |= PMinSize;
  799. X            }
  800. X            if ((sizehints.flags & PMaxSize)==0) {
  801. X             sizehints.max_width = DisplayWidth(dpy, scr);
  802. X             sizehints.flags |= PMaxSize;
  803. X            }
  804. X           }
  805. X      }
  806. X     }
  807. X     else ox = oy = 2;
  808. X     /* change fixed point to one that shouldn't move */
  809. X     if (oy == 0) { 
  810. X      y = y1; y1 = y2; y2 = y;
  811. X     }
  812. X     if (ox == 0) { 
  813. X      x = x1; x1 = x2; x2 = x;
  814. X     }
  815. X     if (sizehints.flags & PMinSize) {
  816. X      minwidth = sizehints.min_width;
  817. X      minheight = sizehints.min_height;
  818. X     } else {
  819. X      minwidth = 0;
  820. X      minheight = 0;
  821. X     }
  822. X     if (sizehints.flags & PMaxSize) {
  823. X      maxwidth = max(sizehints.max_width, minwidth);
  824. X      maxheight = max(sizehints.max_height, minheight);
  825. X     } else {
  826. X      maxwidth = DisplayWidth(dpy, scr);
  827. X      maxheight = DisplayHeight(dpy, scr);
  828. X     }
  829. X     if (sizehints.flags & PResizeInc) {
  830. X      xinc = sizehints.width_inc;
  831. X      yinc = sizehints.height_inc;
  832. X     } else {
  833. X      xinc = 1;
  834. X      yinc = 1;
  835. X     }
  836. X     switch (ox) {
  837. X     case 0:
  838. X      pop_x = x1 - PWidth;
  839. X      break;
  840. X     case 1:
  841. X      pop_x = x1 + (hsize - PWidth) / 2;
  842. X      break;
  843. X     case 2:
  844. X      pop_x = x1;
  845. X      break;
  846. X     }
  847. X     switch (oy) {
  848. X     case 0:
  849. X      pop_y = y1 - PHeight;
  850. X      break;
  851. X     case 1:
  852. X      pop_y = y1 + (vsize - PHeight) / 2;
  853. X      break;
  854. X     case 2:
  855. X      pop_y = y1;
  856. X      break;
  857. X     }
  858. X     /*
  859. X      * Double expose on the target window is too expensive for some reason
  860. X      * or another. Paint the popup window in the upper left hand
  861. X      * corner of the screen if RootResizeBox is FALSE. This is also
  862. X      * more-or-less consistent with the position of the map request popup.
  863. X      */
  864. X     if (RootResizeBox == TRUE)
  865. X      values.x = values.y = 0;
  866. X     else {
  867. X      if (pop_x < 0 || pop_x > (DisplayWidth(dpy, scr) - PWidth))
  868. X           pop_x = 0;
  869. X      if (pop_y < 0 || pop_y > (DisplayHeight(dpy, scr) - PHeight))
  870. X           pop_y = 0;
  871. X      values.x = pop_x;
  872. X      values.y = pop_y;
  873. X     }
  874. X     values.stack_mode = Above;
  875. X     XConfigureWindow(dpy, Pop, CWX|CWY|CWStackMode, &values);
  876. X     XMapWindow(dpy, Pop);
  877. X     if (Grid) {
  878. X      num_vectors = (*storegrid_func)(box,
  879. X                      MIN(x1, x2), MIN(y1, y2),
  880. X                      MAX(x1, x2), MAX(y1, y2));
  881. X     }
  882. X     else {
  883. X      num_vectors = (*storebox_func)(box,
  884. X                     MIN(x1, x2), MIN(y1, y2),
  885. X                     MAX(x1, x2), MAX(y1, y2));
  886. X     }
  887. X
  888. X     /*
  889. X      * If we freeze the server, then we will draw solid
  890. X      * lines instead of flickering ones during resizing.
  891. X      */
  892. X     if (Freeze)
  893. X      XGrabServer(dpy);
  894. X     /* protect us from ourselves */
  895. X     Snatched = True;
  896. X     /*
  897. X      * Process any pending exposure events before drawing the box.
  898. X      */
  899. X     while (QLength(dpy) > 0) {
  900. X      XPeekEvent(dpy, b_ev);
  901. X      if (b_ev->xany.window == RootWindow(dpy, scr))
  902. X           break;
  903. X      GetButton(b_ev);
  904. X     }
  905. X     if (ResizeRelative) {
  906. X      x_offset = x2 - x0;
  907. X      y_offset = y2 - y0;
  908. X     }
  909. X     else
  910. X      x_offset = y_offset = 0;
  911. X
  912. X     /*
  913. X      * Now draw the box.
  914. X      */
  915. X     DrawBox();
  916. X     Frozen = window;
  917. X     stop = FALSE;
  918. X     x = -1; y = -1;
  919. X     
  920. X     while (!stop) {
  921. X      if (x != x2 || y != y2) {
  922. X           x = x2; y = y2;
  923. X
  924. X           /*
  925. X        * If we've frozen the server, then erase
  926. X        * the old box.
  927. X        */
  928. X           if (Freeze)
  929. X            DrawBox();
  930. X           
  931. X           if (Grid) {
  932. X            num_vectors = (*storegrid_func)(box,
  933. X                            MIN(x1, x), MIN(y1, y),
  934. X                            MAX(x1, x), MAX(y1, y));
  935. X           }
  936. X           else {
  937. X            num_vectors = (*storebox_func)(box,
  938. X                           MIN(x1, x), MIN(y1, y),
  939. X                           MAX(x1, x), MAX(y1, y));
  940. X           }
  941. X           
  942. X           if (Freeze)
  943. X            DrawBox();
  944. X           
  945. X           {
  946. X            int Hsize = (hsize - width_offset) / xinc;
  947. X            int Vsize = (vsize - height_offset) / yinc;
  948. X            int pos = 4;
  949. X            PText[0] = (Hsize>99) ? (Hsize / 100 + '0')      : ' ';
  950. X            PText[1] = (Hsize>9)  ? ((Hsize / 10) % 10 + '0') : ' ';
  951. X            PText[2] = Hsize % 10 + '0';
  952. X            if (Vsize>99) PText[pos++] = Vsize / 100 + '0';
  953. X            if (Vsize>9)  PText[pos++] = (Vsize / 10) % 10 + '0';
  954. X            PText[pos++] = Vsize % 10 + '0';
  955. X            while (pos<7) PText[pos++] = ' ';
  956. X           }
  957. X           /*
  958. X        * If the font is not fixed width we have to
  959. X        * clear the window to guarantee that the characters
  960. X        * that were there before are erased.
  961. X        */
  962. X           if (!(PFontInfo->per_char))
  963. X            XClearWindow(dpy, Pop);
  964. X           XDrawImageString(
  965. X                dpy, Pop, PopGC,
  966. X                PPadding, PPadding+PFontInfo->ascent,
  967. X                PText, PTextSize);
  968. X      }
  969. X      if (!Freeze) {
  970. X           DrawBox();
  971. X           DrawBox();
  972. X      }
  973. X
  974. X      if (XPending(dpy) && !ProcessRequests(box, num_vectors) &&
  975. X          GetButton(b_ev)) {
  976. X           if ((b_ev->xany.type != ButtonPress) && 
  977. X           (b_ev->xany.type != ButtonRelease))
  978. X            continue; /* spurious menu event... */
  979. X
  980. X           if (Freeze) {
  981. X            DrawBox();
  982. X            Frozen = (Window)0;
  983. X            XUngrabServer(dpy);
  984. X           }
  985. X
  986. X           if (b_ev->xany.type == buttonConfirmEvent &&
  987. X           b_ev->xbutton.button == button)
  988. X            stop = TRUE;
  989. X           else {
  990. X            XUnmapWindow(dpy, Pop);
  991. X            ResetCursor(button);
  992. X            Snatched = False;
  993. X            ungrab_pointer();
  994. X            Leave(TRUE)
  995. X           }
  996. X      }
  997. X      else {
  998. X           XQueryPointer(dpy, RootWindow(dpy, scr), &root, 
  999. X                 &sub_win, &x2, &y2, &junk_x, &junk_y, &ptrmask);
  1000. X           x2 += x_offset;    /* get to anchor point */
  1001. X           y2 += y_offset;
  1002. X      }
  1003. X      hsize = max(min(abs (x2 - x1), maxwidth), minwidth);
  1004. X      hsize = makemult(hsize - minwidth, xinc) + minwidth;
  1005. X
  1006. X      vsize = max(min(abs(y2 - y1), maxheight), minheight);
  1007. X      vsize = makemult(vsize - minheight, yinc) + minheight; 
  1008. X      if (sizehints.flags & PAspect) {
  1009. X           if ((hsize * sizehints.max_aspect.y > 
  1010. X            vsize * sizehints.max_aspect.x)) {
  1011. X            delta = makemult((hsize * sizehints.max_aspect.y /
  1012. X                      sizehints.max_aspect.x) - vsize, 
  1013. X                     yinc);
  1014. X            if ((vsize + delta <= maxheight))
  1015. X             vsize += delta;
  1016. X            else {
  1017. X             delta = makemult(hsize - 
  1018. X                      (sizehints.max_aspect.x *
  1019. X                       vsize/sizehints.max_aspect.y), 
  1020. X                      xinc);
  1021. X             if (hsize - delta >= minwidth)
  1022. X                  hsize -= delta; 
  1023. X            }
  1024. X           }  
  1025. X           if (hsize * sizehints.min_aspect.y < vsize *
  1026. X           sizehints.min_aspect.x) {
  1027. X            delta = makemult((sizehints.min_aspect.x * 
  1028. X                      vsize/sizehints.min_aspect.y) - hsize, 
  1029. X                     xinc);
  1030. X            if (hsize + delta <= maxwidth)
  1031. X             hsize += delta;
  1032. X            else {
  1033. X             delta = makemult(vsize - 
  1034. X                      (hsize*sizehints.min_aspect.y /
  1035. X                       sizehints.min_aspect.x), 
  1036. X                      yinc); 
  1037. X             if (vsize - delta >= minheight)
  1038. X                vsize -= delta; 
  1039. X            }
  1040. X           }
  1041. X           
  1042. X      }
  1043. X      if (ox == 0)
  1044. X           x2 = x1 - hsize;
  1045. X      else
  1046. X           x2 = x1 + hsize;
  1047. X      
  1048. X      if (oy == 0)
  1049. X           y2 = y1 - vsize;
  1050. X      else
  1051. X           y2 = y1 + vsize;
  1052. X      
  1053. X     }
  1054. X     if (x2 < x1) {
  1055. X      x = x1; x1 = x2; x2 = x;
  1056. X     }
  1057. X     if (y2 < y1) {
  1058. X      y = y1; y1 = y2; y2 = y;
  1059. X     }
  1060. X     XUnmapWindow(dpy, Pop);
  1061. X     if ((x1 !=client_info.x) || (y1 != client_info.y) || 
  1062. X     (hsize != client_info.width) ||
  1063. X     (vsize != client_info.height)) {
  1064. X      XWindowChanges xwc;
  1065. X           
  1066. X      xwc.x = x1;
  1067. X      xwc.y = y1;
  1068. X      xwc.width = hsize;
  1069. X      xwc.height = vsize;
  1070. X      ConfigureWindow(window, CWX | CWY | CWHeight | CWWidth, &xwc);
  1071. X     }
  1072. X     Snatched = False;
  1073. X     ungrab_pointer();
  1074. X     Leave(TRUE)
  1075. X}
  1076. X
  1077. XCheckConsistency(hints)
  1078. XXSizeHints *hints;
  1079. X{
  1080. X     Entry("CheckConsistency")
  1081. X
  1082. X     if (hints->min_height < 0)
  1083. X      hints->min_height = 0;
  1084. X     if (hints->min_width < 0)
  1085. X      hints->min_width = 0;
  1086. X     
  1087. X     if (hints->max_height <= 0 || hints->max_width <= 0)
  1088. X      hints->flags &= ~PMaxSize;
  1089. X     
  1090. X     hints->min_height = min(DisplayHeight(dpy, scr), hints->min_height);
  1091. X     hints->min_width =  min(DisplayWidth(dpy, scr),  hints->min_width);
  1092. X     
  1093. X     hints->max_height = min(DisplayHeight(dpy, scr), hints->max_height);
  1094. X     hints->max_width =  min(DisplayWidth(dpy, scr),  hints->max_width);
  1095. X     
  1096. X     if ((hints->flags & PMinSize) && (hints->flags & PMaxSize) && 
  1097. X     ((hints->min_height > hints->max_height) ||
  1098. X      (hints->min_width > hints->max_width)))
  1099. X      hints->flags &= ~(PMinSize|PMaxSize);
  1100. X     
  1101. X     if ((hints->flags & PAspect) && 
  1102. X     (hints->min_aspect.x * hints->max_aspect.y > 
  1103. X      hints->max_aspect.x * hints->min_aspect.y))
  1104. X      hints->flags &= ~(PAspect);
  1105. X     Leave_void
  1106. X}
  1107. END_OF_awm/Resize.c
  1108. if test 15515 -ne `wc -c <awm/Resize.c`; then
  1109.     echo shar: \"awm/Resize.c\" unpacked with wrong size!
  1110. fi
  1111. # end of overwriting check
  1112. fi
  1113. if test -f awm/globals.c -a "${1}" != "-c" ; then 
  1114.   echo shar: Will not over-write existing file \"awm/globals.c\"
  1115. else
  1116. echo shar: Extracting \"awm/globals.c\" \(13880 characters\)
  1117. sed "s/^X//" >awm/globals.c <<'END_OF_awm/globals.c'
  1118. X#ident   "%W% %G%"
  1119. X
  1120. X
  1121. X
  1122. X#ifndef lint
  1123. Xstatic char *rcsid_globals_c = "$Header: globals.c,v 1.3 88/07/23 17:26:00 jkh Exp $";
  1124. X#endif  lint
  1125. X#include "X11/copyright.h"
  1126. X/*
  1127. X *
  1128. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  1129. X *
  1130. X * Copyright 1987 by Jordan Hubbard.
  1131. X *
  1132. X *
  1133. X *                         All Rights Reserved
  1134. X *
  1135. X * Permission to use, copy, modify, and distribute this software and its
  1136. X * documentation for any purpose and without fee is hereby granted,
  1137. X * provided that the above copyright notice appear in all copies and that
  1138. X * both that copyright notice and this permission notice appear in
  1139. X * supporting documentation, and that the name of Ardent Computer
  1140. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  1141. X * pertaining to distribution of the software without specific, written
  1142. X * prior permission.
  1143. X *
  1144. X */
  1145. X
  1146. X/*
  1147. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  1148. X *
  1149. X *               All Rights Reserved
  1150. X *
  1151. X * Permission to use, copy, modify, and distribute this software and its
  1152. X * documentation for any purpose and without fee is hereby granted,
  1153. X * provided that the above copyright notice appear in all copies and that
  1154. X * both that copyright notice and this permission notice appear in
  1155. X * supporting documentation, and that the name of Digital Equipment
  1156. X * Corporation not be used in advertising or publicity pertaining to
  1157. X * distribution of the software without specific, written prior permission.
  1158. X *
  1159. X *
  1160. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1161. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1162. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1163. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1164. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1165. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1166. X * SOFTWARE.
  1167. X */
  1168. X
  1169. X/*
  1170. X * MODIFICATION HISTORY
  1171. X *
  1172. X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  1173. X * 001 -- R. Kittell, DEC Storage A/D May 19, 1986
  1174. X *  Added global vars for warp options.
  1175. X * 002 -- Loretta Guarino Reid, DEC Ultrix Engineering Group 
  1176. X *  Western Software Lab. April 17, 1987
  1177. X *  Convert to X11
  1178. X * 003 -- Jordan Hubbard, U.C. Berkeley. Misc new vars.
  1179. X */
  1180. X#include "awm.h"
  1181. X#include "X11/Xutil.h"
  1182. XWindow Pop;            /* Pop up dimension display window. */
  1183. XWindow Frozen;            /* Contains window id of "gridded" window. */
  1184. XXFontStruct *IFontInfo;        /* Icon text font information. */
  1185. XXFontStruct *PFontInfo;        /* Pop-up text font information. */
  1186. XXFontStruct *TFontInfo;        /* Title text font information. */
  1187. XXFontStruct *TFontBoldInfo;    /* Title text (bold) font information. */
  1188. XXFontStruct *GFontInfo;        /* Gadget box text font */
  1189. XPixmap GrayPixmap;        /* Gray pixmap. */
  1190. XPixmap SolidPixmap;        /* Solid pixmap */
  1191. XPixmap IBackPixmap;        /* Icon window background pixmap. */
  1192. XPixel ForeColor;        /* Generic foreground color */
  1193. XPixel BackColor;        /* Generic background color */
  1194. XPixel IBorder;            /* Icon window border color. */
  1195. XPixel PBackground;        /* Pop-up Window background color. */
  1196. XPixel PForeground;        /* Pop-up Window foregrould color */
  1197. XPixel PBorder;            /* Pop-Up Window border color. */
  1198. XPixel IBackground;        /* Icon background (for pixmap) color */
  1199. XPixel IForeground;        /* Icon foreground (for pixmap) color */
  1200. XPixel ITextForeground;        /* Icon text foreground color */
  1201. XPixel ITextBackground;        /* Icon text background color */
  1202. Xchar *Foreground;        /* foreground color (text) */
  1203. Xchar *Background;        /* background color (text) */
  1204. Xchar *WBorder;            /* Window border color */
  1205. Xchar *BBackground;        /* Border context background color */
  1206. Xchar *BForeground;        /* Border context foreground color */
  1207. Xchar *TBackground;        /* Titlebar background color */
  1208. Xchar *TForeground;        /* Titlebar foreground color */
  1209. Xchar *TTextBackground;        /* Titlebar text background color */
  1210. Xchar *TTextForeground;        /* Titlebar text foreground color */
  1211. XCursor ArrowCrossCursor;    /* Arrow cross cursor. */
  1212. XCursor TextCursor;        /* Text cursor used in icon windows. */
  1213. XCursor IconCursor;        /* Icon Cursor. */
  1214. XCursor LeftButtonCursor;    /* Left button main cursor. */
  1215. XCursor MiddleButtonCursor;    /* Middle button main cursor. */
  1216. XCursor RightButtonCursor;    /* Right button main cursor. */
  1217. XCursor TargetCursor;        /* Target (select-a-window) cursor. */
  1218. XCursor TitleCursor;        /* Titlebar cursor */
  1219. XCursor FrameCursor;        /* Border context cursor */
  1220. Xint GadgetBorder;        /* Width of gadget borders */
  1221. Xint ScreenWidth;        /* Display screen width. */
  1222. Xint ScreenHeight;        /* Display screen height. */
  1223. Xint IBorderWidth;        /* Icon window border width. */
  1224. Xint TitleHeight;        /* Height of title bar(s) (in pixels) */
  1225. Xint titleHeight;        /* Derived height of title bar(s) in pixels */
  1226. Xint gadgetHeight;        /* Height of highest gadget */
  1227. Xint NameOffset;            /* Offset for window name */
  1228. Xint TitlePad;            /* Padding for titles */
  1229. Xint PWidth;            /* Pop-up window width. */
  1230. Xint PHeight;            /* Pop-up window height. */
  1231. Xint PBorderWidth;        /* Pop-up window border width. */
  1232. Xint PPadding;            /* Pop-up window padding. */
  1233. Xint Delta;            /* Mouse movement slop. */
  1234. Xint HIconPad;            /* Icon horizontal padding. */
  1235. Xint VIconPad;            /* Icon vertical padding. */
  1236. Xint Pushval;            /* Number of pixels to push window by. */
  1237. Xint BContext;            /* Border context area width (in pixels) */
  1238. Xint RaiseDelay;            /* Number of milliseconds delay before autoraise */
  1239. Xint NumGadgets;            /* Number of gadgets we're using */
  1240. Xint GadgetPad;            /* Amount of padding for gadgets */
  1241. Xint Volume;            /* Audible alarm volume. */
  1242. Xint status;            /* Routine return status. */
  1243. Xint Maxfd;            /* Maximum file descriptors for select(2). */
  1244. Xint BCursor;            /* Border context cursor */
  1245. Xint TCursor;            /* Title context cursor */
  1246. XMenuLink *Menus;        /* Linked list of menus. */
  1247. XGC  IconGC;            /* graphics context for icon */
  1248. XGC  PopGC;            /* graphics context for pop */
  1249. XGC  DrawGC;            /* graphics context for drawing */
  1250. XBinding *Blist;            /* Button/key binding list. */
  1251. X
  1252. XXContext AwmContext;        /* Main context for awm */
  1253. X
  1254. XBoolean Autoselect;        /* Warp mouse to default menu selection? */
  1255. XBoolean Autoraise;        /* Raise window on input focus? */
  1256. XBoolean Borders;        /* Display border context areas? */
  1257. XBoolean ConstrainResize;    /* Don't resize until pointer leaves window */
  1258. XBoolean Freeze;            /* Freeze server during move/resize? */
  1259. XBoolean Grid;            /* Should the m/r box contain a 9 seg. grid. */
  1260. XBoolean ShowName;        /* If True, print window names in titlebars */
  1261. XBoolean Hilite;            /* Should we highlight titles on focus? */
  1262. XBoolean BorderHilite;        /* Should we highlight borders on focus? */
  1263. XBoolean InstallColormap;    /* Should we install colormaps for clients? */
  1264. XBoolean NWindow;        /* Normalize windows? */
  1265. XBoolean NIcon;            /* Normalize icons? */
  1266. XBoolean Push;            /* Relative=TRUE, Absolute=FALSE. */
  1267. XBoolean RootResizeBox;        /* Resize window is placed over sized window? */
  1268. XBoolean ResizeRelative;        /* resizes should be relative to window edge */
  1269. XBoolean Titles;            /* Title bar frob on windows? */
  1270. XBoolean UseGadgets;        /* Gadget bars on titles? */
  1271. XBoolean FrameFocus;        /* Treat the frame as part of the window? */
  1272. XBoolean Reverse;        /* Reverse video? */
  1273. XBoolean SaveUnder;        /* Save unders? */
  1274. XBoolean PushDown;        /* Down=TRUE, Up=FALSE */
  1275. XBoolean Wall;            /* restrict to root window boundries? */
  1276. XBoolean WarpOnRaise;        /* Warp to upper right corner on raise. */
  1277. XBoolean WarpOnIconify;          /* Warp to icon center on iconify. */
  1278. XBoolean WarpOnDeIconify;        /* Warp to upper right corner on de-iconify. */
  1279. XBoolean FocusSetByUser;         /* True if f.focus called */
  1280. XBoolean FocusSetByWM;        /* True if awm set the focus */
  1281. XBoolean Zap;            /* Should the the zap effect be used. */
  1282. Xchar PText[7] = INIT_PTEXT;    /* Pop-up window dummy text. */
  1283. Xint PTextSize = sizeof(PText);    /* Pop-up window dummy text size. */
  1284. Xint Lineno = 1;            /* Line count for parser. */
  1285. XBoolean Startup_File_Error = FALSE;/* Startup file error flag. */
  1286. Xchar Startup_File[NAME_LEN] = "";/* Startup file name. */
  1287. Xchar *TBackPixmapData;        /* Bitmap data file title background */
  1288. Xchar *TBoldPixmapData;        /* ditto, except highlighted */
  1289. Xchar *BBackPixmapData;        /* Border context background pixmap data */
  1290. Xchar *BBoldPixmapData;        /* Border context bold pixmap data */
  1291. Xchar *awmPath;            /* Optional pathlist to search for pixmaps */
  1292. Xchar **Argv;            /* Pointer to command line parameters. */
  1293. Xchar **Environ;            /* Pointer to environment. */
  1294. X
  1295. Xchar gray_bits[] = {
  1296. X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
  1297. X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
  1298. X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
  1299. X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa
  1300. X};
  1301. X
  1302. Xchar solid_bits[] = {
  1303. X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1304. X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1305. X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  1306. X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  1307. X};
  1308. X
  1309. Xint scr;
  1310. XDisplay *dpy;
  1311. X
  1312. X#ifdef NEATEN
  1313. Xint AbsMinWidth;
  1314. Xint AbsMinHeight;
  1315. XBoolean RetainSize;
  1316. XBoolean KeepOpen;
  1317. XBoolean Fill;
  1318. XBoolean UsePriorities;
  1319. XBoolean FixTopOfStack;
  1320. Xchar *PrimaryIconPlacement;
  1321. Xchar *SecondaryIconPlacement;
  1322. X#endif
  1323. X
  1324. X/*
  1325. X * Keyword lookup table for parser.
  1326. X */
  1327. XKeyword KeywordTable[] =
  1328. X{
  1329. X    { "autoselect",    IsBoolean,    &Autoselect, 0 },
  1330. X    { "autoraise",    IsBoolean,    &Autoraise, 0 },
  1331. X    { "freeze",        IsBoolean,    &Freeze, 0 },
  1332. X    { "hilite",        IsBoolean,    &Hilite, 0 },
  1333. X    { "rootResizeBox",    IsBoolean,    &RootResizeBox, 0 },
  1334. X    { "titles",        IsBoolean,    &Titles, 0 },
  1335. X    { "gadgets",    IsBoolean,    &UseGadgets, 0 },
  1336. X    { "grid",        IsBoolean,    &Grid, 0 },
  1337. X    { "showName",    IsBoolean,    &ShowName, 0,},
  1338. X    { "normali",    IsBoolean,    &NIcon, 0 },
  1339. X    { "normalw",    IsBoolean,    &NWindow, 0 },
  1340. X    { "pushRelative",    IsBoolean,    &Push, 0 },
  1341. X    { "reverse",    IsBoolean,    &Reverse, 0 },
  1342. X    { "wall",        IsBoolean,    &Wall, 0 },
  1343. X    { "frameFocus",    IsBoolean,    &FrameFocus, 0 },
  1344. X    { "warpOnIconify",    IsBoolean,    &WarpOnIconify, 0 },
  1345. X    { "warpOnDeIconify",IsBoolean,    &WarpOnDeIconify, 0 },
  1346. X    { "warpOnRaise",    IsBoolean,    &WarpOnRaise, 0 },
  1347. X#ifdef NEATEN
  1348. X    { "retainSize",    IsBoolean,    &RetainSize, 0 },
  1349. X    { "keepOpen",    IsBoolean,    &KeepOpen, 0 },
  1350. X    { "fill",        IsBoolean,    &Fill, 0 },
  1351. X    { "usePriorities",    IsBoolean,    &UsePriorities },
  1352. X    { "fixTopOfStack",    IsBoolean,    &FixTopOfStack },
  1353. X#endif
  1354. X    { "zap",        IsBoolean,    &Zap, 0 },
  1355. X    { "gadget",        IsGadget,    0, 0 },
  1356. X    { "f.beep",        IsImmFunction,    0, Beep },
  1357. X    { "f.circledown",    IsImmFunction,    0, CircleDown },
  1358. X    { "f.circleup",    IsImmFunction,    0, CircleUp },
  1359. X    { "f.continue",    IsImmFunction,    0, Continue },
  1360. X    { "f.decorate",    IsFunction,    0, FDecorate },
  1361. X    { "f.exit",        IsQuitFunction,    0, Quit },
  1362. X    { "f.focus",    IsFunction,    0, Focus },
  1363. X    { "f.unfocus",    IsImmFunction,    0, UnFocus },
  1364. X    { "f.iconify",    IsFunction,    0, Iconify },
  1365. X    { "f.lower",    IsFunction,    0, Lower },
  1366. X    { "f.menu",        IsMenuMap,    0, DoMenu },
  1367. X    { "f.action",    IsAction,    0, DoAction },
  1368. X    { "f.move",        IsDownFunction,    0, Move },
  1369. X    { "f.moveopaque",    IsDownFunction,    0, MoveOpaque },
  1370. X    { "f.newiconify",    IsDownFunction,    0, NewIconify },
  1371. X    { "f.neaten",    IsImmFunction,    0, Neaten },
  1372. X    { "f.pause",    IsImmFunction,    0, Pause },
  1373. X    { "f.pushdown",    IsFunction,    0, ShoveDown },
  1374. X    { "f.pushleft",    IsFunction,    0, ShoveLeft },
  1375. X    { "f.pushright",    IsFunction,    0, ShoveRight },
  1376. X    { "f.pushup",    IsFunction,    0, ShoveUp },
  1377. X    { "f.raise",    IsFunction,    0, Raise },
  1378. X    { "f.redraw",    IsDownFunction,    0, Redraw },
  1379. X    { "f.refresh",    IsImmFunction,    0, Refresh },
  1380. X    { "f.resize",    IsDownFunction,    0, Resize },
  1381. X    { "f.restart",    IsQuitFunction,    0, Restart },
  1382. X    { "f.destroy",      IsDownFunction, 0, DestroyClient },
  1383. X    { "f.nodecorate",   IsFunction,     0, FNoDecorate },
  1384. X    { "menu",        IsMenu,        0, 0 },
  1385. X    { "resetbindings",    IsParser,    0, ResetBindings },
  1386. X    { "resetmenus",    IsParser,    0, ResetMenus },
  1387. X    { "resetgadgets",    IsParser,    0, ResetGadgets },
  1388. X    { NULL,        NULL,        NULL, NULL }
  1389. X};
  1390. X/*
  1391. X * Key expression table for parser.
  1392. X */
  1393. XKeyExpr KeyExprTbl[] = {
  1394. X    { "ctrl", ControlMask },
  1395. X    { "c", ControlMask },
  1396. X    { "lock", LockMask },
  1397. X    { "l", LockMask },
  1398. X    { "meta", Mod1Mask },
  1399. X    { "m", Mod1Mask },
  1400. X    { "shift", ShiftMask },
  1401. X    { "s", ShiftMask },
  1402. X    { "mod1", Mod1Mask },
  1403. X    { "mod2", Mod2Mask },
  1404. X    { "mod3", Mod3Mask },
  1405. X    { "mod4", Mod4Mask },
  1406. X    { "mod5", Mod5Mask },
  1407. X    { NULL, NULL }
  1408. X};
  1409. X/*
  1410. X * Context expression table for parser.
  1411. X */
  1412. XContExpr ContExprTbl[] = {
  1413. X    { "icon", ICON },
  1414. X    { "i", ICON },
  1415. X    { "root", ROOT },
  1416. X    { "r", ROOT },
  1417. X    { "window", WINDOW },
  1418. X    { "w", WINDOW },
  1419. X    { "t", TITLE },
  1420. X    { "title", TITLE },
  1421. X    { "g", GADGET },
  1422. X    { "gadget", GADGET },
  1423. X    { "border", BORDER },
  1424. X    { "b", BORDER },
  1425. X    { NULL, NULL }
  1426. X};
  1427. X
  1428. X/*
  1429. X * Gravity expressions for parser.
  1430. X */
  1431. XGravityExpr GravityExprTbl[] = {
  1432. X    { "noGravity", NoGadgetGravity },
  1433. X    { "nogravity", NoGadgetGravity },
  1434. X    { "NoGravity", NoGadgetGravity },
  1435. X    { "leftGravity", LeftGadgetGravity },
  1436. X    { "leftgravity", LeftGadgetGravity },
  1437. X    { "LeftGravity", LeftGadgetGravity },
  1438. X    { "rightGravity", RightGadgetGravity },
  1439. X    { "rightgravity", RightGadgetGravity },
  1440. X    { "RightGravity", RightGadgetGravity },
  1441. X    { "centerGravity", CenterGadgetGravity },
  1442. X    { "centerGravity", CenterGadgetGravity },
  1443. X    { "CenterGravity", CenterGadgetGravity },
  1444. X    { NULL, NULL}
  1445. X};
  1446. X
  1447. X/*
  1448. X * Button expression table for parser.
  1449. X */
  1450. XButtonModifier ButtModTbl[] = {
  1451. X    { "left", LeftMask },
  1452. X    { "leftbutton", LeftMask },
  1453. X    { "l", LeftMask },
  1454. X    { "middle", MiddleMask },
  1455. X    { "middlebutton", MiddleMask },
  1456. X    { "m", MiddleMask },
  1457. X    { "right", RightMask },
  1458. X    { "rightbutton", RightMask },
  1459. X    { "r", RightMask },
  1460. X    { "move", DeltaMotion },
  1461. X    { "motion", DeltaMotion },
  1462. X    { "delta", DeltaMotion },
  1463. X    { "boogie", DeltaMotion },
  1464. X    { "truckin", DeltaMotion }, /* it's been a silly day... */
  1465. X    { "down", ButtonDown },
  1466. X    { "d", ButtonDown },
  1467. X    { "up", ButtonUp },
  1468. X    { "u", ButtonUp },
  1469. X    { NULL, NULL }
  1470. X};
  1471. END_OF_awm/globals.c
  1472. if test 13880 -ne `wc -c <awm/globals.c`; then
  1473.     echo shar: \"awm/globals.c\" unpacked with wrong size!
  1474. fi
  1475. # end of overwriting check
  1476. fi
  1477. echo shar: End of archive 7 \(of 13\).
  1478. cp /dev/null ark7isdone
  1479. MISSING=""
  1480. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
  1481.     if test ! -f ark${I}isdone ; then
  1482.     MISSING="${MISSING} ${I}"
  1483.     fi
  1484. done
  1485. if test "${MISSING}" = "" ; then
  1486.     echo You have unpacked all 13 archives.
  1487.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1488. else
  1489.     echo You still need to unpack the following archives:
  1490.     echo "        " ${MISSING}
  1491. fi
  1492. ##  End of shell archive.
  1493. exit 0
  1494. Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
  1495.